# coding:utf-8
# @Time    : 2021/12/4 21:57
# @Author  : Martin
""""
__new__讲解
http://c.biancheng.net/view/5484.html
"""


#


#
#
# def test_kwargs(a, b=2):
#     print(a, b)
#
#
# def test_params(*args, **kwargs):
#     print(args, kwargs)
#
#
# class demoBase:
#     instances_created = None
#
#     def __init__(self, a, b):
#         print(self.instances_created)
#
#
# class demoClass(demoBase):
#
#     def __new__(cls, *args, **kwargs):
#         print("__new__():", cls, args, kwargs)
#         instance = super().__new__(cls)
#         instance.instances_created = f"url{args[2]}"
#
#         return instance
#
#     def __init__(self, a, b, attribute):
#         super().__init__(a, b)
#
# def kwargs_test(**kwargs):
#     print(kwargs)
import requests


def wrapper_run(fun):
    def run(*args, **kwargs):
        print("start wrapper_run")
        return fun(*args, **kwargs)

    return run


@wrapper_run
def method_a():
    print('this is method_a')
    return Demo()


def func_click():
    method_a().click()


class Demo():

    def click(self):
        print('this is demo click')


def method2(a):
    print('method2')

    def method1(a):
        return print('1')

    return method1


def test_args(a, b=1, d=2):
    print(a, b, d)
    pass


def test(*args, **kwargs):
    test_args(*args, **kwargs)


def test2(a=1, b=None, **kwargs):
    print(kwargs['c'])
    print(1)


# class ObjectBase:
#     # def locate(self):
#     #     print('ObjectBase.locat')
#     def click(self):
#         self.locate()
#         print('ObjectBase.Click')
#
#
# class Object1(ObjectBase):
#     def locate(self):
#         print('Object1.locate')


# def test1(a=None, b=None):
#     print(a, b)


# def test1(a=None):
#     print(a)

import sys


def fibonacci(n):  # 生成器函数 - 斐波那契
    a, b, counter = 0, 1, 0
    while True:
        if (counter > n):
            return
        yield a
        a, b = b, a + b
        counter += 1


# f 是一个迭代器，由生成器返回生成


if __name__ == '__main__':
    r=requests.delete('http://192.168.56.10:30001/session/4f6e6b51f74e4bc1cf04b98ac7fc32c5/de')
    print(r.status_code)
    # f = fibonacci(10)
    # while True:
    #     try:
    #         print(next(f), end=" ")
    #     except StopIteration:
    #         sys.exit()

    # test1(a=2,b=1)
    # a = 1
    # b = 2
    # max = a if a > b else b
    # print(max)
    # print([a if i > 1 else 2 for i in range(10)])



    # dic1 = {'a': 1, 'b': ' '}
    # dic2 = {'b': '', 'a': 1}
    # assert dic1 == dic2
    # O1 = Object1()
    # O1.click()
    # test2(**{'a': 2, 'b': 3, 'c': 4})

    # dm = Demo()
    # setattr(dm,'ss',1)
    # print(dm.ss)
    # c = 1,
    # cc = {'a': 7}
    # test_args(*c)
    # method2(22)
    # func_click()
    # # test1 = de
    # moClass(1, 2, "abc")
    # test_args(*[1,2])
    # test_kwargs(**{'a':1})
    # test_params(1,2,c=2)
    # a = [1, 2, 3, 4, 5]
    # for i in a:
    #     if i == 2:
    #         # print(f"index={a.index(i)}")
    #         del (a[a.index(i)])
    #     print(i)
    # print(a)
    # a=(1,2)
    # b=[1,2]
    # assert  a is b
    # [print(i) for i in range(1)]
    # a = [lambda x: x*i for i in range(3)]
    # # print(type(a[0]), "---", a[0])
    #
    # for i in a[0](4):
    # a=1

    # a = {'a': 1, 'b': 2}
    # b = {'b': 2, 'a': 1}
    # print(a == b)

    # for i in range(2):
    #     print(f'i={i}')
    #     is_a = False
    #     for a in range(10):
    #         print(f'a={a}')
    #
    #         if a == 11:
    #             is_a = True
    #             break
    #     if not is_a:
    #         raise ValueError('error')
